﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lrd.Template.Core.Infrastructure.Extensions;
using Lrd.Template.Core.Infrastructure.Filter;
using Lrd.Template.Core.Infrastructure.Reflection;

namespace Lrd.Template.Core.Infrastructure.Modules
{
    /// <summary>
    /// 模块类型查询器
    /// </summary>
    public class ModuleBaseTypeFinder : BaseTypeFinderBase<ModuleBase>, IModuleBaseTypeFinder
    {

        public ModuleBaseTypeFinder(IAllAssemblyFinder allAssemblyFinder) : base(allAssemblyFinder)
        { 
          
        }

        /// <summary>
        /// 重写以实现所有项的查找
        /// </summary>
        /// <returns></returns>
        protected override Type[] FindAllItems()
        {
            var types = base.FindAllItems();
            var modules = types.Select(o => o.BaseType).Where(t => t.IsNotNull() && t.IsClass && !t.IsAbstract).ToArray();
            return types.Except(modules).ToArray();
        }

    }
}
